package org.greatstorm.dao.impl;

import java.util.List;

import org.greatstorm.dao.GeneralDao;
import org.greatstorm.dao.TagDao;
import org.greatstorm.entity.EntityObject;
import org.greatstorm.entity.Tag;
import org.greatstorm.util.Filter;
import org.greatstorm.util.Operator;

import com.google.inject.Singleton;

@Singleton
public class TagDaoImpl extends GeneralDao implements TagDao {

	@Override
	protected String getEntityName() {
		return Tag.KIND;
	}

	@Override
	public EntityObject getTagByName(String tag) {
		Filter f1 = new Filter();
		f1.setKey(Tag.TAG_NAME);
		f1.setOpt(Operator.OPT_EQUAL);
		f1.setValue(tag);

		List<EntityObject> list = this.getEntityListByFilter(f1);

		if (list.size() == 0)
			return null;

		return list.get(0);
	}

}
